import axios from 'axios'

// const baseUrl = 'https://api.vcct.info'
const baseUrl = 'http://192.168.0.139:7777'
const apiSuffix = '/api/v1'

const serverAddress = baseUrl + apiSuffix
// const serverAddress = local;
// const serverAddress = test;
// const serverAddress = remote;

export default {
  getUrl: function (url) {
    return serverAddress + url
  },
  postLogin: function (url, params) {
    return axios.post(this.getUrl(url), params).catch(err => console.log(err))
  },
  post: function (url, params = {}) {
    return axios.post(this.getUrl(url), params)
      .then(resp => resp.data)
      .catch(err => console.log(err))
  },
  get: function (url, params) {
    return axios.get(this.getUrl(url), params)
      .then(resp => resp.data)
      .catch(err => console.log(err))
  }
}
